import Vue from 'vue'
import vuex from 'vuex'
import tabbar from './modules/tabbar.js'
import navbar from './modules/navbar.js'
import userInfo from './modules/user.js'

Vue.use(vuex)


const store = new vuex.Store({
	state: {
		storeValue: 0,
	},
	mutations: {
		$uStore(state, payload) {
			let nameArr = payload.name.split('.');
			let len = nameArr.length;
			if (nameArr.length >= 2) {
				let obj = state[nameArr[0]];
				for (let i = 1; i < len - 1; i++) {
					obj = obj[nameArr[i]];
				}
				obj[nameArr[len - 1]] = payload.value;
			} else {
				state[payload.name] = payload.value;
			}
		}
	},
	getters: {},
	actions: {},
	modules: {
		tabbar,
		navbar,
		userInfo,
	}
})

export default store